package com.basker.pisces.springcloud.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.basker.pisces.springcloud.context.TokenRequestInterceptor;
import com.basker.pisces.springcloud.locale.ClientLocaleInterceptor;
import com.basker.pisces.springcloud.rpc.ClientRpcContextInterceptor;
import com.basker.pisces.springcloud.trace.ClientTraceContextInterceptor;

import feign.Feign;

@Configuration
@ConditionalOnClass(Feign.class)
public class FeignRequestInterceptorConfig {
    /**
     * 设置rpc上下文的拦截器
     *
     * @return
     */
    @Bean
    public ClientRpcContextInterceptor clientRpcContextInterceptor() {
        return new ClientRpcContextInterceptor();
    }

    /**
     * 设置locale的拦截器
     *
     * @return
     */
    @Bean
    public ClientLocaleInterceptor localInterceptor() {
        return new ClientLocaleInterceptor();
    }

    /**
     * 设置token的拦截器器
     *
     * @return
     */
    @Bean
    public TokenRequestInterceptor tokenInterceptor() {
        return new TokenRequestInterceptor();
    }

    /**
     * 设置trace的拦截器
     *
     * @return
     */
    @Bean
    public ClientTraceContextInterceptor traceContextRequestInterceptor() {
        return new ClientTraceContextInterceptor();
    }
}
